﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;

namespace Registro_de_Venta_Ate.Entidades
{
    public class NCliente
    {
        private static SqlConnection GetConnection()
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = @"Password=12345;Persist Security Info=True;User ID=Mauricio;Initial Catalog=DCM_VentasAte;Data Source=mauricio-pc\sqlexpress";
            return con;
        }
        public static DataTable GetClientes()
        {
            SqlConnection con = GetConnection();
            SqlCommand comando = new SqlCommand();
            comando.Connection = con;
            comando.CommandType = CommandType.Text;
            comando.CommandText = "select id, telefono, nombre, direccion, zona, distrito from TCliente";
            using (con)
            {
                con.Open();
                SqlDataReader reader = comando.ExecuteReader();
                DataTable table = new DataTable();
                table.Load(reader);
                return table;
            }
        }

    }
}
